//
//  Define.h
//  PetExchange
//
//  Created by a on 2020/12/17.
//

#ifndef Define_h
#define Define_h

#define  MYAPP ((AppDelegate *)[UIApplication sharedApplication].delegate)

//欢迎
#define WelcomeFlag @"first1"

#pragma mark - 文件
//定义存储类型
#define PICSTYPE       @"picstype"    //图片
#define VIDEOSTYPE     @"videostype"   //视频
#define AUDIOSTYPE     @"audiostype"  //音频
#define DOCUMENTYPE     @"documenttype" //文档(此处指音频)

//个文件夹名称
#define IMPORTAUDIOSTYPE     @"importaudiostype"  //导入音频
#define CREATEAUDIOSTYPE     @"createaudiostype"  //生成音频

#pragma mark - 颜色
#define MyColor(str)    [MYColor colorWithHexString:str]
#define MyColorAlpha(str,a)  [MYColor colorWithHexString:str alpha:a]
//可以修改此处主题色 导航
#define ThemeColor [UIColor colorWithHexString:@"#0F1011"]
//主view
#define ciThemeColor [UIColor colorWithHexString:@"#25282D"]

#define MYBlock [UIColor colorWithHexString:@"333333"]
#define MYOrange [UIColor colorWithHexString:@"ffe400"]
#define MYRed [UIColor colorWithHexString:@"#E04148"]
#define MYGreen [UIColor colorWithHexString:@"1EA61E"]
#define MYBlue [UIColor colorWithHexString:@"2666e4"]

#pragma mark - 与屏幕相关

#define  LL_iPhoneX \
({BOOL isPhoneX = NO;\
if (@available(iOS 11.0, *)) {\
isPhoneX = [[UIApplication sharedApplication] delegate].window.safeAreaInsets.bottom > 0.0;\
}\
(isPhoneX);})

//屏幕尺度
#define SCREENSCALE [UIScreen mainScreen].scale
//屏幕宽高
#define MY_Screen_W  [[UIScreen mainScreen] bounds].size.width
#define MY_Screen_H  [[UIScreen mainScreen] bounds].size.height

#define MY_SCALE_WIDTH(w)  round((MY_Screen_W/390.0*(w)))
#define MY_SCALE_HEIGHT(h)  round((MY_Screen_W/390.0*(h)))

//下面安全区域的高度
#define  SafeBottomMargin         (LL_iPhoneX ? 34.f : 0.f)
#define SafeSCREEN_HEIGHT   MY_Screen_H - SafeBottomMargin
//上方导航高度
#define NAVIH (LL_iPhoneX ? 88.f : 64.f)
//导航栏高度2
#define NAVITEMPH (LL_iPhoneX ? 44:20)
#define NAVIPHONEXH (LL_iPhoneX ? 24:0)

////底部导航高度
#define barH (LL_iPhoneX ? (49.f+34.f) : 49.f)
//屏幕尺度
#define SCREENSCALE [UIScreen mainScreen].scale

//相对宽
#define pixw(p)  (([[UIScreen mainScreen] bounds].size.width/390.0)*p)

#pragma mark - 字体
#define MY_PriceNumber_Font(p)   [UIFont fontWithName:@"DINCondensed-Bold" size:MY_Screen_W/390.0*p]
//正常字体
#define MY_SCALE_FONT(p) [UIFont systemFontOfSize:MY_Screen_W/390*p]
//加粗字体
#define MY_SCALE_BoldFont(p) [UIFont boldSystemFontOfSize:MY_Screen_W/390*p]

#define  MY_SCALE_RegularFONT(p) [UIFont fontWithName:@"PingFangSC-Regular" size:MY_Screen_W/390.0*p]

#define  MY_SCALE_HeavyFONT(p) [UIFont fontWithName:@"PingFangSC-Semibold" size:MY_Screen_W/390.0*p]
#define  MY_SCALE_LightFONT(p) [UIFont fontWithName:@"PingFangSC-Light" size:MY_Screen_W/390.0*p]
//极细
#define MY_SCALE_UltralightFONT(p) [UIFont fontWithName:@"PingFangSC-Ultralight" size:MY_Screen_W/390.0*p]
#define MY_SCALE_ThinFONT(p) [UIFont fontWithName:@"PingFangSC-Thin" size:MY_Screen_W/390.0*p]
//粗
#define MY_SCALE_MediumFONT(p) [UIFont fontWithName:@"PingFangSC-Medium" size:MY_Screen_W/390.0*p]
//极粗
#define MY_SCALE_SemiboldFONT(p) [UIFont fontWithName:@"PingFangSC-Semibold" size:MY_Screen_W/390.0*p]

//自定义字体
#define MY_SCALE_BebasFONT(p) [UIFont fontWithName:@"Bebas" size:MY_Screen_W/390.0*p]

#pragma mark - 国际化
#define Localized(key) [[NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"%@",[[NSUserDefaults standardUserDefaults] objectForKey:@"appLanguage"]] ofType:@"lproj"]] localizedStringForKey:(key) value:nil table:"infoPlist"]
#define LocalizedString(key) NSLocalizedString(key, nil)

#pragma mark - 强弱引用
// *  强弱引用转换，用于解决代码块（block）与强引用对象之间的循环引用问题
// *  调用方式: `@weakify(object)`实现弱引用转换，`@strongify(object)`实现强引用转换
// *
// *  示例：
// *  @weakify(object)
// *  [obj block:^{
// *      @strongify(object)
// *      strong_object = something;
// *  }];
 
#ifndef    weakify
#if __has_feature(objc_arc)
#define weakify(object)    autoreleasepool{} __weak __typeof__(object) weak##_##object = object;
#else
#define weakify(object)    autoreleasepool{} __block __typeof__(object) block##_##object = object;
#endif
#endif
#ifndef    strongify
#if __has_feature(objc_arc)
#define strongify(object) try{} @finally{} __typeof__(object) strong##_##object = weak##_##object;
#else
#define strongify(object) try{} @finally{} __typeof__(object) strong##_##object = block##_##object;
#endif
#endif

#pragma mark - 日志打印
#ifdef DEBUG
#define DLog(FORMAT, ...) fprintf(stderr, "[%s %s %s-%d] %s\n", __DATE__ , __TIME__, [[[NSString stringWithUTF8String: __FILE__] lastPathComponent] UTF8String], __LINE__, [[[NSString alloc] initWithData:[[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] dataUsingEncoding:NSUTF8StringEncoding] encoding:NSNonLossyASCIIStringEncoding] UTF8String]?[[[NSString alloc] initWithData:[[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] dataUsingEncoding:NSUTF8StringEncoding] encoding:NSNonLossyASCIIStringEncoding] UTF8String]:[[NSString stringWithFormat: FORMAT, ## __VA_ARGS__] UTF8String]);
#else
#define DLog(...)
#endif


#endif /* Define_h */


